#include <stdint.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>          /* ioctl */
#include <stdlib.h>
#include <stdio.h>
#include "vtl.h"


int main(int argc, char **argv) {
    int f;
	int ret=0;
    char *buf = malloc(1000);
	memset(buf,0,1000);
	sprintf(buf,"This is my string");
    f = open("VTL", O_RDWR);

    printf("Opened device...%d\n", f);
	printf("Sending IOCTL: %d\n", ioctl(f,IOCTL_CREATE_TAPE, &ret));
	printf("ret: %d\n",ret);
	printf("Sending IOCTL: %d\n", ioctl(f,IOCTL_REPLACE_TAPE, ret));

    printf("Writing 1000...returned: %d bytes\n", write(f,buf,30));
	memset(buf,0,1000);
	printf("Sending IOCTL: %d\n", ioctl(f,IOCTL_REWIND_CURRENT_TAPE));
	printf("Reading 1000...returned: %d bytes\n", read(f,buf,1000));
    printf("Got: %s\n",buf);

    printf("Closing..\n");
    close(f);
    return 0;
}

